import Vue from "vue";
import Vuex from "vuex";
import axios from "axios";

Vue.use(Vuex);

const myServer = axios.create({
  baseURL: "http://localhost:3000",
});

export default new Vuex.Store({
  state: {
    studentList: [],
  },
  mutations: {
    async initStu(state: any) {
      state.studentList = (await myServer.get("students")).data.reverse();
    },
  },
  actions: {
    initStu({ commit }) {
      commit("initStu");
    },
  },
  modules: {},
});
